<template>
  <div class="app-container">
    <basic-container v-show="showSearch">
      <common-search @handleQuery="handleQuery" @resetQuery="resetQuery">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" size="mini">
          <el-form-item label="单证编码" prop="billCode">
            <el-input v-model.trim="queryParams.billCode" placeholder="请输入单证代码" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="报关单号" prop="entryId">
            <el-input v-model.trim="queryParams.entryId" placeholder="请输入报关单号" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="进出口类型" prop="iEFlag" label-width="100px">
            <el-select v-model="queryParams.iEFlag" placeholder="请选择进出口类型" clearable @change="handleQuery">
              <el-option v-for="dict in dict.type.sys_i_e_flag" :key="dict.value" :label="dict.label"
                         :value="dict.value"/>
            </el-select>
          </el-form-item>
          <el-form-item label="车牌号" prop="veNo">
            <el-input v-model.trim="queryParams.veNo" placeholder="请输入车牌号码" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="进出场" prop="ieType">
            <el-select v-model.trim="queryParams.ieType" placeholder="请选择进出场类型" clearable @change="handleQuery">
              <el-option v-for="dict in dict.type.sys_i_e_type" :key="dict.value" :label="dict.label" :value="dict.value"/>
            </el-select>
          </el-form-item>

          <el-form-item label="IC卡号" prop="icNo">
            <el-input v-model.trim="queryParams.icNo" placeholder="请输入IC卡号" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="前箱号" prop="contaBno">
            <el-input v-model.trim="queryParams.contaBno" placeholder="请输入前箱号" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="后箱号" prop="contaFno">
            <el-input v-model.trim="queryParams.contaFno" placeholder="请输入后箱号" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>

          <el-form-item label="验放结果" prop="checkResult">
            <el-select v-model.trim="queryParams.checkResult" placeholder="请输入验放结果" clearable>
              <el-option v-for="dict in dict.type.sys_release_result" :key="dict.value" :label="dict.label"
                        :value="dict.value"/>
            </el-select>
          </el-form-item>
          <el-form-item label="批次号" prop="manifestId">
            <el-input v-model.trim="queryParams.manifestId" placeholder="请输入运输批次号" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="过卡类型" prop="veGrossType">
            <el-select v-model.trim="queryParams.veGrossType" placeholder="请输入过卡类型" clearable>
              <el-option v-for="dict in dict.type.ve_gross_type_list" :key="dict.value" :label="dict.label"
                        :value="dict.value"/>
            </el-select>
          </el-form-item>
          <el-form-item label="放行时间" prop="checkTime">
            <el-date-picker clearable v-model="checkTime" type="daterange" value-format="yyyy-MM-dd HH:mm:ss"
                            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                            :default-time="['00:00:00','23:59:59']"
                            @keyup.enter.native="handleQuery">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="场站信息" prop="areaNo">
            <el-select v-model.trim="queryParams.areaNo" placeholder="请选择场站信息" filterable clearable
                       @change="selAreaNo">
              <el-option v-for="dict in fieldOptions" :key="dict.value" :label="dict.label"
                         :value="dict.value"/>
            </el-select>
          </el-form-item>
          <el-form-item label="通道信息" prop="channelNo">
            <el-select v-model.trim="queryParams.channelNo" placeholder="请选择通道信息" clearable filterable>
              <el-option v-for="dict in channelInfoList" :key="dict.value" :label="dict.label"
                         :value="dict.value"/>
            </el-select>
          </el-form-item>
          <el-form-item label="企业名称" prop="declCopName">
            <el-input v-model.trim="queryParams.declCopName" placeholder="请输入企业名称" clearable
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
        </el-form>
      </common-search>
    </basic-container>

    <basic-container>
      <el-row :gutter="10" class="mb8 el-row">
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['system:gather:remove']"
          >删除</el-button>
        </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      <el-col :span="18">
        <el-row>
          <el-descriptions :data="countResult" :column="4">
            <el-descriptions-item label="今日总数" :labelStyle="labelICount" :contentStyle="qtyStyle">{{
                countResult.qty
              }}
            </el-descriptions-item>
            <el-descriptions-item label="进卡口车辆数" :labelStyle="labelICount" :contentStyle="iCountStyle">
              {{ countResult.iCount }}
            </el-descriptions-item>
            <el-descriptions-item label="出卡口车辆数" :labelStyle="labelICount" :contentStyle="ECountStyle">
              {{ countResult.eCount }}
            </el-descriptions-item>
            <el-descriptions-item label="滞留车辆数" :labelStyle="labelICount" :contentStyle="nCountStyle">
              <el-button
                style="border: none;text-align: center;padding: 0;height: 21px; width:100%;background: #FFEDED; color: red"
                @click="vehicleDetail" icon="el-icon-search">
                {{ countResult.nCount }}
              </el-button>
            </el-descriptions-item>
          </el-descriptions>
        </el-row>
      </el-col>
    </el-row>

      <el-table v-loading="loading" :data="hdGatherList" @selection-change="handleSelectionChange" stripe border size="small">
        <el-empty slot="empty" :image="require('@/assets/images/empty.png')" :image-size="260"></el-empty>
        <el-table-column align="center" fixed type="selection"/>
        <el-table-column label="场站名称" align="center" prop="areaName" min-width="150" show-tooltip-when-overflow/>
        <el-table-column label="通道名称" align="center" prop="channelName" width="200" show-tooltip-when-overflow/>
        <el-table-column label="车牌号码" align="center" prop="veNo" width="110" show-tooltip-when-overflow/>
        <el-table-column label="IC卡号" align="center" prop="icNo" width="120" show-tooltip-when-overflow/>
        <el-table-column label="验放结果" align="center" prop="checkResult">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_release_result" :value="scope.row.checkResult"/>
          </template>
        </el-table-column>
        <el-table-column label="LED提示" align="center" prop="ledHint" min-width="150" show-overflow-tooltip/>
        <el-table-column label="过卡时间" align="center" prop="checkTime" width="180"/>
        <el-table-column label="企业名称" align="center" prop="declCopName" width="180" show-overflow-tooltip/>
        <el-table-column label="批次号" align="center" prop="manifestId" width="120" show-tooltip-when-overflow/>
        <el-table-column label="报关单号" align="center" prop="entryId" v-if="false" width="120"
                        show-tooltip-when-overflow/>
        <el-table-column label="单证编码" prop="billCode" min-width="250" show-tooltip-when-overflow/>
        <el-table-column label="进出口类型" align="center" prop="iEFlag" min-width="100">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_i_e_flag" :value="scope.row.iEFlag"/>
          </template>
        </el-table-column>
        <el-table-column label="地磅重量" align="center" prop="crossWeight"/>
        <el-table-column label="车皮" align="center" prop="veWt"/>
        <el-table-column label="货物重量" align="center" prop="goodsWts"/>
        <el-table-column label="进出场" align="center" prop="ieType">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_i_e_type" :value="scope.row.ieType"/>
          </template>
        </el-table-column>
        <el-table-column label="过卡类型" align="center" prop="veGrossType" width="100">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.ve_gross_type_list" :value="scope.row.veGrossType"/>
          </template>
        </el-table-column>

        <el-table-column label="报关单号" align="center" prop="entryId" width="140" show-tooltip-when-overflow/>
        <el-table-column label="前箱号" align="center" prop="contaFno" width="120" show-tooltip-when-overflow/>
        <el-table-column label="后箱号" align="center" prop="contaBno" width="120" show-tooltip-when-overflow/>
        <el-table-column label="操作" align="center" fixed="right" width="80px" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-view" @click="showDetail(scope.row)">详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
    </basic-container>

    <el-drawer
      title="滞留车辆内容"
      :visible.sync="drawer"
      size="mini"
      :before-close="handleClose" :data="countResult">
      <ul>
        <li style="border-bottom: #e1f3fb 1px solid;" v-for="(item, index) in countResult.veList" :key="index">{{ item }}</li>
      </ul>
    </el-drawer>

    <!-- 添加或修改放行记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="850px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px" :disabled="isViewDisabled">
        <el-row>
          <el-col :span="12">
            <el-form-item label="车牌号码" prop="veNo" label-width="100px">
              <el-input v-model="form.veNo" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="IC卡号" prop="icNo" label-width="100px">
              <el-input v-model="form.icNo" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="前箱号" prop="contaFno" label-width="100px">
              <el-input v-model="form.contaFno" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="后箱号" prop="contaBno" label-width="100px">
              <el-input v-model="form.contaBno" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地磅重量" prop="crossWeight" label-width="100px">
              <el-input v-model="form.crossWeight" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车皮" prop="veWt" label-width="100px">
              <el-input v-model="form.veWt" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="场所名称" prop="areaName" label-width="100px">
              <el-input v-model="form.areaName" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="通道名称" prop="channelName" label-width="100px">
              <el-input v-model="form.channelName" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="进出类型" prop="ieType" label-width="100px">
              <el-select v-model="form.ieType" placeholder="">
                <el-option v-for="dict in dict.type.sys_i_e_type" :key="dict.value" :label="dict.label"
                           :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="载货重量" prop="goodsWts" label-width="100px">
              <el-input v-model="form.goodsWts" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="批次号" prop="manifestId" label-width="100px">
              <el-input v-model="form.manifestId" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报关单号" prop="entryId" label-width="100px">
              <el-input v-model="form.entryId" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单证代码" prop="billCode" label-width="100px">
              <el-input v-model="form.billCode" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="转关单号" prop="customsTransferNo" label-width="100px">
              <el-input v-model="form.customsTransferNo" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="采集时间" prop="gatherTime" label-width="100px">
              <el-date-picker clearable size="small" v-model="form.gatherTime" type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss" placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="验放时间" prop="checkTime" label-width="100px">
              <el-date-picker clearable size="small" v-model="form.checkTime" type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss" placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="验放结果" prop="checkResult" label-width="100px">
              <el-select v-model="form.checkResult" placeholder="">
                <el-option v-for="dict in dict.type.sys_release_result" :key="dict.value" :label="dict.label"
                           :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="验放提示" prop="checkHint" label-width="100px">
              <el-input v-model="form.checkHint" type="textarea" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-if="!isViewDisabled">确 定</el-button>
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>

    <!-- 详情dialog-->
    <el-dialog :visible.sync="detailOpen" width="50%" append-to-body :close-on-click-modal="false">
      <el-descriptions class="margin-top" :title="title" :column="2" border :contentStyle="CS">

        <el-descriptions-item>
          <template slot="label">
            序列号
          </template>
          {{ form.seqNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            场所码
          </template>
          {{ form.areaNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            场所名称
          </template>
          {{ form.areaName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            通道号
          </template>
          {{ form.channelNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            通道名称
          </template>
          {{ form.channelName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            进出场
          </template>
          <dict-tag :options="dict.type.sys_i_e_type" :value="form.ieType"/>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            放行时间
          </template>
          {{ form.gatherTime }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            IC卡号
          </template>
          {{ form.icNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            车牌号
          </template>
          {{ form.veNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            进出口类型
          </template>
          <dict-tag :options="dict.type.sys_i_e_flag" :value="form.iEFlag"/>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            地磅重量
          </template>
          {{ form.crossWeight }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            过卡类型
          </template>
          <dict-tag :options="dict.type.ve_gross_type_list" :value="form.veCrossType"/>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            提运单号
          </template>
          {{ form.billNo }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            批次号
          </template>
          {{ form.manifestId }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            业务名称
          </template>
          {{ form.businessName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            报关单号
          </template>
          {{ form.entryId }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            货物重量
          </template>
          {{ form.goodsWt }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            货物名称
          </template>
          {{ form.goodsName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            单证编号
          </template>
          {{ form.billCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            空车重
          </template>
          {{ form.veWt }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            采集方式
          </template>
          {{ form.gatherModel }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            海关编码
          </template>
          {{ form.customsCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            转关单号
          </template>
          {{ form.customsTransferNo }}
        </el-descriptions-item>

        <el-descriptions-item>
          <template slot="label">
            挂车重量
          </template>
          {{ form.veTrayWt }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            集装箱重量
          </template>
          {{ form.containerWt }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            验放结果
          </template>
          <dict-tag :options="dict.type.sys_release_result" :value="form.checkResult"/>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            验放提示
          </template>
          {{ form.checkHint }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            操作提示
          </template>
          {{ form.operationHint }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            LED提示
          </template>
          {{ form.ledHint }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            处理放行时间
          </template>
          {{ form.checkTime }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            备注说明
          </template>
          {{ form.rmk }}
        </el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer" style="text-align: center;">
        <el-button @click="closeDetail">关闭</el-button>
      </div>
    </el-dialog>

    <!-- 打印框内容 -->
    <el-dialog id="printContent" :title="printObj.popTitle" width="750px" :visible="printFlag" append-to-body>
      <h4 style="line-height: 40px;border-bottom: 1px black solid;margin-top: 0">
        <span>打印日期：{{ printTime }}</span>
        <span style="padding-right: 10px;float: right">第1页</span>
      </h4>
      <el-table show-summary highlight-current-row :data="printDataList" :summary-method="getSummaries" class="bor_1"
                stripe border>
        <el-table-column label="车牌号码" align="center" prop="veNo"/>
        <el-table-column label="货物名称" align="center" prop="goodsName"/>
        <el-table-column label="批次号" align="center" prop="manifestId"/>
        <el-table-column label="进出场" align="center" prop="ieType" width="80px">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_i_e_type" :value="scope.row.ieType"/>
          </template>
        </el-table-column>
        <el-table-column label="放行时间" align="center" prop="checkTime" width="95px"/>
        <el-table-column label="地磅重量" align="center" prop="crossWeight" width="80"/>
        <el-table-column label="空车重" align="center" prop="veWt" width="80"/>
        <el-table-column label="货物重量" align="center" prop="goodsWts" width="80"/>
      </el-table>
      <!--      <h4 style="line-height: 40px;border-top: 1px black solid;margin-bottom: 0">
              <span style="padding-left: 10px;color: red">*注：白色-存根 粉红色- 黄色-检验检疫 蓝色-货主 绿色-财务</span>
            </h4>-->
      <div slot="footer" align="center" class="dialog-footer ">
        <el-button type="danger" class="el-button el-button--danger el-button--medium no-print" v-print="printObj">打
          印
        </el-button>
        <el-button type="primary" class="el-button el-button--primary el-button--medium no-print" @click="cancel">返 回
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getGatherById,
  listGather,
  listGatherByIds,
  getGatherCount,
  delGather
} from "@/api/kmwlpts/gkHdGather";
import print from 'vue-print-nb';
import {
  parseTime
} from "@/utils/ruoyi";
import {selectFieldDictList} from "@/api/system/baseFieldInfo";
import {queryChannelInfoList} from "@/api/system/channelInfo";

export default {
  name: "GkHdGather",
  dicts: ['sys_i_e_type', 'sys_i_e_flag', 'sys_release_result', 've_gross_type_list'],
  data() {
    return {
      CS: {
        'text-align': 'left',  //文本居中
        'min-width': '30%',   //最小宽度
        'width': '35%',
        'word-break': 'break-all'  //过长时自动换行
      },
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      labelICount: {
        'width': '200px',
        'text-align': 'center'
      },
      iCountStyle: {
        'width': '200px',
        'background': '#FFF8E6',
        'text-align': 'center',
        'color': '#FFBF00',
        'border-radius': '5px'
      },
      ECountStyle: {
        'width': '200px',
        'background': '#E8F4FF',
        'color': '#46A6FF',
        'text-align': 'center',
        'border-radius': '5px'
      },
      nCountStyle: {
        'width': '200px',
        'text-align': 'center',
        'border-radius': '5px',
        'cursor': 'pointer'
      },
      qtyStyle: {
        'width': '200px',
        'background': '#46A6FF',
        'color': '#FFFFFF',
        'text-align': 'center',
        'border-radius': '5px'
      },
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      drawer: false,
      //统计结果
      countResult: {
        veList: []
      },
      //显示检查项目列表
      checkItemTableVisible: false,
      //详情显示的时候，表单编辑禁用
      isViewDisabled: false,
      detailOpen: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 放行记录表格数据
      hdGatherList: [],
      // 弹出层标题
      title: "",
      //
      checked: true,
      //
      checkTime: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        areaNo: null,
        channelNo: null,
        iEFlag: null,
        ieType: null,
        icNo: null,
        veNo: null,
        checkResult: null,
        manifestId: null,
        businessId: null,
        entryId: null,
        goodsName: null,
        billCode: null,
        customsCode: null,
        declCopName: null,
        from: null,
        to: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      //打印初始化
      printLoading: true,
      printObj: {
        id: 'printContent',
        printable: 'id',
        type: 'pdf',
        ignoreClass: 'no-print',
        scanStyles: false,
        popTitle: '放行单据详情打印',
        extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/> '
      },
      //打印对象
      printForm: {},
      //批量打印默认为禁用状态
      btnChangeEnable: true,
      //打印弹窗
      printFlag: false,
      //打印时间
      printTime: '',
      //打印弹窗记录数组
      printDataList: [],
      fieldOptions: [],
      //通道信息队列
      channelInfoList: [],
      selAreaName: null,
    };
  },
  directives: {
    print
  },
  created() {
    this.getList();
    this.getChannelInfo();
    this.getZcFieldInfo();
  },
  methods: {
    selAreaNo(val) {
      this.selAreaName = val;
      this.getChannelInfo();
    },
    //获取通道信息
    getChannelInfo() {
      queryChannelInfoList(this.selAreaName).then(res => {
        this.channelInfoList = res;
      })
    },
    // 场所列表
    getZcFieldInfo() {
      selectFieldDictList("").then(response => {
        this.fieldOptions = response;
      });
    },

    //显示滞留车辆信息
    vehicleDetail() {
      this.drawer = true;
    },
    //关闭滞留车辆信息
    handleClose() {
      this.drawer = false;
      this.getList();
    },
    /** 查询放行记录列表 */
    getList() {
      this.loading = true;
      listGather(this.queryParams).then(response => {
        this.hdGatherList = response.rows;
        this.total = response.total;
      });
      getGatherCount(this.queryParams).then(response => {
        this.countResult = response.data;
        this.loading = false;
      });
    },
    //计算合计
    getSummaries(param) {
      const {
        columns,
        data
      } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '本页合计'
        } else if (index === 7 || index === 5 || index === 6) {
          const values = data.map(item => Number(item[column.property]))
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
          } else {
            sums[index] = 'N/A'
          }
        } else {
          sums[index] = ''
        }
      })
      return sums
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateHdGather(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addHdGather(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      //关闭打印弹窗
      this.printFlag = false;
    },
    closeDetail() {
      this.detailOpen = false;
      this.getList();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.checkTime != null) {
        this.queryParams.from = this.checkTime[0];
        this.queryParams.to = this.checkTime[1]
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.selAreaName = null;
      this.checkTime = [];
      this.handleQuery();

    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      //启用批量打印按钮状态
      this.btnChangeEnable = this.ids.length <= 0;
    },
    //显示打印内容列表
    showPrint() {
      this.printFlag = true;
      this.printTime = parseTime(Date.now());
      listGatherByIds(this.ids).then(response => {
        this.printDataList = response.data;
      });
    },

    //显示详情
    showDetail(row) {
      //this.reset();
      //关闭表单编辑模式
      //this.isViewDisabled = true;
      this.detailOpen = true;
      const id = row.id;
      getGatherById(id).then(response => {
        this.form = response.data;
        //this.open = true;
        this.title = "放行记录详情";
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        seqNo: null,
        areaNo: null,
        areaName: null,
        channelNo: null,
        channelName: null,
        ieType: null,
        gatherTime: null,
        icNo: null,
        veNo: null,
        crossWeight: null,
        checkResult: null,
        checkHint: null,
        billNo: null,
        manifestId: null,
        businessId: null,
        businessName: null,
        entryId: null,
        goodsWts: null,
        goodsName: null,
        billCode: null,
        veEmpty: null,
        veWt: null,
        gatherModel: null,
        rmk: null,
        syncDate: null,
        checkTime: null,
        useTime: null,
        checkAiHint: null,
        checkAiResult: null,
        checkBody: null,
        transportId: null,
        customsCode: null,
        customsTransferNo: null,
        errorCode: null,
        veTrayWt: null,
        containerWt: null
      };
      this.resetForm("form");
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function() {
        return delGather(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有放行记录数据项？').then(() => {
        this.exportLoading = true;
        return exportHdGather(queryParams);
      }).then(response => {
        this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {
      });
    }
  }

};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>

@page {
  margin: 0;
  size: auto;
}

.el-drawer__body {
  overflow: auto;
}

@media print {

  .el-table__header-wrapper .el-table__header .el-dialog__wrapper {
    width: 750px !important;
  }

  .el-table__body-wrapper .el-table__body {
    width: 750px !important;
  }

  .no-print {
    display: none;
  }
}

.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266;
}

.el-select.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266 !important;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  color: #606266;
}

::v-deep .bor_1 {
  border: 1px black solid;
}

::v-deep input[disabled],
input:disabled,
input.disabled {
  -webkit-text-fill-color: #606266;
  background: #F5F7FA;
  -webkit-opacity: 1;
  opacity: 1;
  cursor: not-allowed;
}
</style>
